home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Tools / vg-2.03 / video / ati.c next >
Encoding:
C/C++ Source or Header  |  1995-05-03  |  2.0 KB  |  107 lines

  1. /*
  2.  * Copyright (C) 1990-1992 by Michael Davidson.
  3.  * All rights reserved.
  4.  *
  5.  * Permission to use, copy, modify, and distribute this software
  6.  * and its documentation for any purpose and without fee is hereby
  7.  * granted, provided that the above copyright notice appear in all
  8.  * copies and that both that copyright notice and this permission
  9.  * notice appear in supporting documentation.
  10.  *
  11.  * This software is provided "as is" without express or implied warranty.
  12.  */
  13.  
  14. /*
  15.  * ati.c    - support routines for ATI VGA Wonder
  16.  */
  17.  
  18. #include    "vdev.h"
  19. #include    "svga.h"
  20.  
  21. /*
  22.  * table of video modes supported for ATI VGA Wonder
  23.  */
  24. #define    GRAPHICS    (SVGA_MODE_SUPPORTED | SVGA_GRAPHICS_MODE)
  25. #define    TEXT        (SVGA_MODE_SUPPORTED | SVGA_TEXT_MODE)
  26.  
  27. static struct svga_mode_info ati_modes[] =
  28. {
  29.     {    800,    600,    8,    0x63,    GRAPHICS },
  30.     {    640,    480,    8,    0x62,    GRAPHICS },
  31.     {    640,    400,    8,    0x61,    GRAPHICS },
  32.     {    320,    200,    8,    0x13,    GRAPHICS },
  33.     {    80,    25,    0,    0x03,    TEXT     },
  34.     {    0,    0,    0,    0x00,    0     }
  35. };
  36.  
  37. /*
  38.  * ATI VGA Wonder extended register
  39.  */
  40. static unsigned        ati_reg;
  41.  
  42. #define    ATI_IDX        (ati_reg)
  43. #define    ATI_DAT        (ati_reg + 1)
  44.  
  45. static void    ati_bank_switch();
  46. static int    ati_present();
  47.  
  48. /*ARGSUSED*/
  49. int
  50. ati_init(
  51.     char    *name,
  52.     struct vdev *v
  53.     )
  54. {
  55.     int        r;
  56.  
  57.     if (! (r = ati_present()))
  58.     return -1;
  59.  
  60.     svga_setup(v, ati_modes, ati_bank_switch);
  61.  
  62.     v->v_name        = "ATI VGA Wonder";
  63.  
  64.     ati_reg    = VideoBiosAddress[0x10] | (VideoBiosAddress[0x11] << 8);
  65.     V86IOEnable(ati_reg, 2);
  66.  
  67.     return 0;
  68. }
  69.  
  70. int
  71. ati_probe()
  72. {
  73.     return ati_present();
  74. }
  75.  
  76. void
  77. ati_io_enable()
  78. {
  79.     ati_reg    = VideoBiosAddress[0x10] | (VideoBiosAddress[0x11] << 8);
  80.     V86IOEnable(ati_reg, 2);
  81.     V86IOEnable(0x56ee, 2);
  82. }
  83.  
  84. static int
  85. ati_present()
  86. {
  87.     return (memcmp(VideoBiosAddress + 0x31, "761295520", 9) == 0);
  88. }
  89.  
  90. /*
  91.  * ati_bank_switch()
  92.  */
  93. static void
  94. ati_bank_switch(
  95.     int        x
  96.     )
  97. {
  98.     x &= 7;
  99.     x <<= 1;
  100.  
  101.     outb(ATI_IDX, 0xb2);
  102.     x |= (inb(ATI_DAT) & 0xe1);
  103.     outb(ATI_IDX, 0xb2);
  104.     outb(ATI_DAT, x);
  105. }
  106.  
  107.